const pool = require("../config/mysqlPool")

const service = {
    // 查找新闻分类表的数据
    findCatlist(callback) {
        pool.query(`select * from ht_cat`, (err, results) => {
            err ? callback(false) : callback(results)
        })
    },
    // 查找新闻列表接口
    findList(pno, count, callback) {
        pool.query(`select nid, title,cat_id  from ht_news limit ? , ? ; select count (*) allNum from ht_news`, [(pno - 1) * count, count - 0], (err, results) => {
            err ? callback(false) : callback(results)
        })
    },
    //新闻详情页
    findDetails(nid, callback) {
        pool.query(`select detail from ht_news  where nid =?`, [nid], (err, results) => {
            err ? callback(false) : callback(results)
        })
    }
}


module.exports = service